//******************************************************************************
//    CG^2 - Client of GUCAS Gateway
//    Copyright (C) 2010 Rui Diao
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
//    Author's Email: diaorui@lsec.cc.ac.cn doraemonok@163.com
//    Website: http://lsec.cc.ac.cn/~diaorui/software/cg2/
//******************************************************************************

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtNetwork/QHttp>
#include <QTimer>
#include <QUrl>
#include <QTextCodec>
#include <QDebug>
#include <QTimer>
#include <QMessageBox>
#include <QDateTime>
#include <QMenu>
#include <QCloseEvent>
#include <QSystemTrayIcon>
#include <QSettings>
#include <QDesktopWidget>
#include "ui_mainWindow.h"

class MainWindow : public QMainWindow, Ui::MainWindow {
    Q_OBJECT
public:
    MainWindow();
    QSystemTrayIcon *trayIcon;
    QStringList cookie;
    QString host;
    QString userAgent;
    QHttp *httpLogin;
    QHttp *httpConnect;
    QHttp *httpMessage;
    QHttp *httpRemainFee;
    QHttp *httpDisconnect;
    QHttp *httpKickOff;
    QTimer *timerUpdate;
    QStringList labelNameList;
    QString userId;
    QString password;
    int domain;
    int loginType;
    bool quit;
    QString toolTip[3];
    
public slots:
    void loginGateway();
    void getCookie(const QHttpResponseHeader &);
    void checkLogin(bool);
    void connectNetwork();
    void checkConnect(bool);
    void updateMessage();
    void checkMessage(bool);
    void onDisconnected(bool);
    void disconnectNetwork();
    void closeEvent(QCloseEvent *event);
    void updateRemainFee();
    void checkRemainFee(bool);
    void onSystemTrayIconClicked(QSystemTrayIcon::ActivationReason);
    void onPushBottonConnectClicked();
    void alwaysOnTopChanged(int);
    void readSettings();
    void saveSettings();
    void kickOff(QString);
};


#endif // MAINWINDOW_H
